package com.woniu.cinema.domain;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;

import java.util.Arrays;

public class Test {

    public static void main(String[] args) throws JsonProcessingException {
        JsonObj jsonObj = new JsonObj();
        DatePrice datePrice1 = new DatePrice();
        datePrice1.put("2009-01-01",120d);
        datePrice1.put("2010-01-01",100d);

        jsonObj.setDatePriceList(Arrays.asList(datePrice1));
        jsonObj.setAaa("aaa");
        jsonObj.setBbb("bbb");

        //对象转换成json字符串
        ObjectMapper mapper = new ObjectMapper();
        String jsonStr = mapper.writeValueAsString(jsonObj);
        System.out.println(jsonStr);



        //把json字符串转回对象
        JsonObj jsonObj2 = mapper.readValue(jsonStr, JsonObj.class);

        System.out.println(jsonObj2);
    }
}
